Skip to content

Fix GH-22422: define ZEND_TRACK_ARENA_ALLOC in php_config.h#22439

Merged
iliaal merged 1 commit into
php:masterfrom
iliaal:fix/gh-22422-zend-track-arena-alloc-php-config
Jun 24, 2026
Merged

Fix GH-22422: define ZEND_TRACK_ARENA_ALLOC in php_config.h#22439
iliaal merged 1 commit into
php:masterfrom
iliaal:fix/gh-22422-zend-track-arena-alloc-php-config

Conversation

@iliaal

@iliaal iliaal commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

ZEND_TRACK_ARENA_ALLOC switches the zend_arena struct layout under AddressSanitizer but was only added to the core CFLAGS, so it never reached php_config.h. A phpize-built extension inherits php_config.h, not the core CFLAGS, and therefore compiled the untracked layout while core used the tracked one; calling zend_arena_destroy on a core-created arena from such an extension leaked every tracked allocation (78 leaks reproduced via zend_test_compile_to_ast). AC_DEFINE it so the layout stays consistent across core and separately built extensions.

Fixes #22422

ZEND_TRACK_ARENA_ALLOC selects an alternative zend_arena struct layout
for AddressSanitizer, but it was only appended to the core CFLAGS, never
recorded in php_config.h. Extensions built separately with phpize inherit
php_config.h rather than the core CFLAGS, so they compiled the untracked
layout while core used the tracked one. Destroying a core-created arena
from such an extension leaked every tracked allocation. Define it with
AC_DEFINE so core and extensions agree on the layout.

Fixes phpGH-22422

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an expert regarding this part of the engine, but the reasoning seems sound, I'm not seeing obvious issues in the diff and trying to build against mismatching struct layouts is surely going to cause issues.

@iliaal iliaal merged commit 2565bf8 into php:master Jun 24, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zend_test_compile_to_ast leaks memory when PHP is compiled with --enable-address-sanitizer

2 participants